'use strict';
const db = uniCloud.database()
const   dbCmd = db.command
exports.main = async (event, context) => {
	//event为客户端上传的参数
	
	
	try{
		if(typeof event.data == 'string'){
		  event.data = eval('('+event.data+')')
		}
		
		if (event.doc) {
			return db.collection(event.collection).doc(event.doc).update({
				...event.data
			})
		} else{
			return db.collection(event.collection).where({...event.where}).update({
				...event.data
			})
		}
		
		
		
		
		
	}catch(e){
		//TODO handle the exception
	}
	
	

	
	//返回数据给客户端
	return event
};
